<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <input type="text">
    <button>确定</button>

    <div class="screen"></div>

    <script>
        let input = document.querySelector('input');
        let screen = document.querySelector('.screen');

        let toGuess = Math.floor(Math.random()*100 + 1);
        console.log(toGuess);

        let button = document.querySelector('button');

        button.onclick = function() {
            let curNum = parseInt(input.value);
            if(isNaN) {
                screen.innerHTML = '输入非法';
                return;
            }
            if(curNum < toGuess) {
                screen.innerHTML = '猜低了';
            }else if(curNum > toGuess) {
                screen.innerHTML = '猜高了';
            }else {
                screen.innerHTML = '猜对了';
            }
        }


    </script>
</body>
</html>